473,467 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Touch Screen Buttons and Completion ComboBoxes

Hi,

I am trying to develop an application for a touch screen using buttons
for the numeric pad with Completion ComboBoxes.

At the moment I am having a problem sending the button presses to my
Completion ComboBox using sendkey.wait. From the keyboard (that will
not exist for my final application) I can enter text into my
Completion and the selection completes as expected.

In the attached demo program I can type using the keyboard

Type Selection Box shows
4 " 440 - Line 0"
44 " 440 - Line 0"
444 " 444 - Line 4"

However when I press the four button on my form I get.

Type Selection Box shows
4 " 440 - Line 0"
4 line clears

I assume that this is related to the fact that the focus is changing
from the ComboBox to the button during the press. Then I am forcing
the focus back to the Completion ComboBox. Not the same as typing
with a keyboard where the focus does not change.

What can I do so I can have both keyboard and button pressing to work
correctly in my Completion ComboBox? Is Sendkeys the way to go?

I have attached the shortest demo program I could develop. I hope
that this is suitable to demostrate my question.

Thanks for your time in reviewing my question. I have not been clear
please ask.

Tanaka

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace keypad
{
public class mdtclientForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private System.Windows.Forms.Button FourButton;
private CompletionComboBox CompletionComboBox;

private string strLostFocus;

public mdtclientForm()
{

InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.FourButton = new System.Windows.Forms.Button();
this.CompletionComboBox = new keypad.CompletionComboBox();
this.SuspendLayout();

this.FourButton.Location = new System.Drawing.Point(100, 150);
this.FourButton.Name = "FourButton";
this.FourButton.Size = new System.Drawing.Size(50, 45);
this.FourButton.TabIndex = 29;
this.FourButton.Text = "4";
this.FourButton.Click += new
System.EventHandler(this.NumericPad_Click);

this.CompletionComboBox.Location = new System.Drawing.Point(32,
88);
this.CompletionComboBox.Name = "CompletionComboBox";
this.CompletionComboBox.Size = new System.Drawing.Size(200, 21);
this.CompletionComboBox.TabIndex = 3;
this.CompletionComboBox.LostFocus += new
System.EventHandler(this.COMBOBOX_LostFocus);
this.CompletionComboBox.Text = "<Press Keys or Buttons>";
this.CompletionComboBox.Items.AddRange(new object[] {
"440 - Line 0",
"441 - Line 1",
"442 - Line 2",
"443 - Line 3",
"444 - Line 4 ",
"445 - Line 5",
"446 - Line 5"});
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.FourButton);
this.Controls.Add(this.CompletionComboBox);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new mdtclientForm());
}

private void NumericPad_Click(object sender, System.EventArgs e)
{
foreach (Control controls in this.Controls)
{
if (controls.Name == strLostFocus)
{
if (Object.ReferenceEquals(controls.GetType(),
typeof(CompletionComboBox)))
{
CompletionComboBox mycontrol = new CompletionComboBox();
Button button = (Button) sender;
if(controls.CanFocus)
{
controls.Focus();
SendKeys.SendWait(button.Text);
}
}
}
}
}

private void COMBOBOX_LostFocus (object sender, System.EventArgs e)
{
CompletionComboBox comboBox = (CompletionComboBox) sender;
strLostFocus = comboBox.Name;
}
}

public class CompletionComboBox : ComboBox
{
public event System.ComponentModel.CancelEventHandler NotInList;

[Category("Behavior")]
public bool LimitToList
{
get { return _limitToList_; }
set { _limitToList_ = value; }
}

protected virtual void
OnNotInList(System.ComponentModel.CancelEventArgs e)
{
if (NotInList != null)
NotInList.Invoke(this, e);
}

protected override void
OnValidating(System.ComponentModel.CancelEventArgs e)
{
if (_limitToList_)
{
int pos = FindStringExact(Text);
if (pos == -1)
OnNotInList(e);
else
this.SelectedIndex = pos;
}
base.OnValidating(e);
}

protected override void OnKeyDown(KeyEventArgs args)
{
_autoComplete_ = args.KeyCode != Keys.Delete && args.KeyCode !=
Keys.Back;
base.OnKeyDown(args);
}

protected override void OnTextChanged(EventArgs args)
{
if( _autoComplete_ )
{
string textEntered = Text;
int index = FindString(textEntered);
if( index >= 0 )
{
_autoComplete_ = false;
SelectedIndex = index;
_autoComplete_ = true;
Select(textEntered.Length, Text.Length);
}
}
base.OnTextChanged(args);
}
private bool _autoComplete_ = true;
private bool _limitToList_ = true;
}
}
Nov 16 '05 #1
0 7930

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: The Bear | last post by:
Is there any documentation for creating a touch screen application using c#. Any information anyone has would be great The Bear. *** Sent via Developersdex http://www.developersdex.com ***...
0
by: Hiroyuki Tanaka | last post by:
Hi All, I am trying to develop an application for a touch screen using buttons for the numeric pad with Completion ComboBoxes. At the moment I am having a problem sending the button presses to...
4
by: Bob | last post by:
I have no experience with them... can I expect that "touch" will fire "mousedown" for any control? Or will I need special controls that understand touchscreen input? Bob
3
by: kiran.challagolla | last post by:
Hi All I want to write a touch screen POS application. I am trying to get this accomplished in c#.net. I have very good experience in developing stand alone applications and web applications using...
2
by: reidarT | last post by:
Do I need to do anything in my application if I want to use a touch screen instead of keyboard/mouse, or is everything controlled by the screen drivers? reidarT
2
by: Simon Verona | last post by:
I know that Windows has a "clickable" keyboard that can pop up when necessary.. I have a touch-screen based application. Is there anyway that I can utilise this keyboard application in windows...
1
by: MikeY | last post by:
Hi Everyone, I'm looking for suggestions for touch screen form sizes. Or better yet dealing with forms very various screen sizes. How to deal with anchoring buttons etc and so they don't overlap...
3
by: Elioth | last post by:
I want to make a program which it work with a touch screen, I need to know if I need any special control or programming in vb.net to do, to the program work with the touch screen? Thanks for...
3
by: brino | last post by:
hi all ! i have a database working on a touch screen. on one of the forms i would like to place some buttons with all numbers so you can enter a numeric value in without using the keyboard. ie....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.